<template>
  <div id="nav">
    <router-link to="/">Home</router-link> |
    <router-link to="/about">About</router-link>
  </div>
  <!--vue3中的路由过渡动画
  // v-slot 中的component 当进入home页面是 就是home页面的组件名
  当进入about页面是 就是about页面的组件名
  component是vue提供的动太渲染组件的组件
  -->
  <router-view class="page" v-slot="{Component}">
    <transition name="slide">
      <component :is="Component"></component>
    </transition>
  </router-view>
</template>

<style lang="scss">
* {
  box-sizing: border-box;
}
html,body, #app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  margin: 0;
}
.page {
  position: absolute;
  top: 70px;
  left: 0;
  height: calc(100% - 70px);
  width: 100%;
  overflow: hidden;
}
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
.slide-enter-from {
  left: 100%;
}
.slide-enter-active, .slide-leave-active {
  transition: all 0.5s linear;
  transform-origin: center;
}
.slide-leave-to {
  left: -100%;
  transform: rotate(180deg) scale(0);
  opacity: 0;
}
</style>
